package com.hepinghospital.user.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.jude.rollviewpager.adapter.StaticPagerAdapter;
import com.hepinghospital.user.util.GlideUtil;
import com.rest.response.BannerListResponse;

import java.util.List;

/**
 * @time 2020/11/18 10:13
 */
public class RollViewAdapter extends StaticPagerAdapter {
    private Context mContext;
    private List<BannerListResponse.Header> list;

    public RollViewAdapter(Context context, List<BannerListResponse.Header> list) {
        this.mContext = context;
        this.list = list;
    }

    @Override
    public View getView(ViewGroup viewGroup, int i) {
        ImageView ivBanner = new ImageView( viewGroup.getContext() );
        //ImageLoader.getInstance().displayImage(list.get(i).getImgUrl(),view);

        GlideUtil.loadRoundImage( mContext, list.get( i ).content, ivBanner );

        ivBanner.setScaleType( ImageView.ScaleType.FIT_XY );
        //view.setScaleType(ImageView.ScaleType.CENTER_CROP);
        ivBanner.setLayoutParams( new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT ) );
        return ivBanner;
    }

    @Override
    public int getCount() {
        return list.size();
    }
}
